package com.smh.a07annotationDemo;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class AnnotationDemo3 {
    public static void main(String[] args) throws ClassNotFoundException, InvocationTargetException, IllegalAccessException {

        //获取MyTestDemo这个类的字节码文件
        Class<?> c = Class.forName("com.smh.a07annotationDemo.MyTestDemo");

        MyTestDemo myTestDemo = new MyTestDemo();

        Method[] methods = c.getDeclaredMethods();
        //获取当前方法上有没有MyTest注解
        for (Method method : methods) {
            method.setAccessible(true);
//            (Class<? extends Annotation>) Class.forName("com.smh.a07annotationDemo.MyTest"
            if (method.isAnnotationPresent(MyTest.class)) {
                System.out.println(method);
                method.invoke(myTestDemo);
            }
        }


    }
}
